package com.isoft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isoft.entity.Device;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DeviceMapper extends BaseMapper<Device> {
    @Select("Select * from device where sno=#{sno}")
    Device haveDevice(Device device);

    @Update("update device set name=#{name}, voltage=#{voltage} , speed=#{speed} , record=#{record} , "+
            "status=#{status} , location=#{location} where sno=#{sno}")
    void update(Device device);

    @Delete(("delete from device where sno=#{sno}"))
    void delete(Device device);

    @Select("Select * from device where sno=#{sno}")
    Device select(String sno);

    @Select("select sno,name,voltage,speed,record,status,location from device")
    List<Device> getAllDevices();

}
